/**   
 * @Title: GetRenjiuShengfuRecordDetailCommunicater.java 
 * @Package com.esun.rabbit2.communicaters.lotteryrecord 
 * @Description: 获取足彩胜负(任九)购彩记录详情
 * @author: City Jiangsy@500wan.com   
 * @date: 2012-1-10 下午8:01:21  
 * Copyright: (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
 */
package com.esun.rabbit2.communicaters.lotteryrecord;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;

import javax.xml.parsers.ParserConfigurationException;

import org.apache.http.client.ClientProtocolException;
import org.xml.sax.SAXException;

import com.esun.config.BussinessCode;
import com.esun.config.Key;
import com.esun.model.ShengFuRenJiuDetailInfo;
import com.esun.model.ShengfuRenjiuTouzhuInfo;
import com.esun.model.UserInfo;
import com.esun.network.ServerCommunicater;

/**
 * @ClassName: GetRenjiuShengfuRecordDetailCommunicater
 * @Description: 获取足彩胜负(任九)购彩记录详情
 * @author: City Jiangsy@500wan.com
 * @date: 2012-1-10 下午8:01:21
 * 
 */
public class GetRenjiuShengfuRecordDetailCommunicater extends ServerCommunicater {
	private String serverMsg = "";

	public boolean isGetDetailSucceed(String lotid, String pid) throws ClientProtocolException, IOException, ParserConfigurationException, SAXException {

		boolean isSucceed = false;

		ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
		list.add(mapItem(BussinessCode.PASER_MID, BussinessCode.MID_GET_LOTRECORD_DETAIL_SF_RJ));
		list.add(mapItem(BussinessCode.PASER_CK, UserInfo.getUserInfo().getUserSession()));
		list.add(mapItem(Key.KEY_LOTID, lotid));
		list.add(mapItem(Key.KEY_PID, pid));

		// 写入服务器返回信息
		super.getServerResponse(list, true);
		setServerMessage(super.getServerMsg());
		if (super.getState() == 100) {
			isSucceed = true;
		} else {
			isSucceed = false;
		}
		return isSucceed;

	}

	private void setServerMessage(String str) {
		serverMsg = str;
	}

	public String getServerMsg() {
		return serverMsg;
	}

	public void updateInfo() {
		ShengFuRenJiuDetailInfo shengfuinfo = ShengFuRenJiuDetailInfo.getInfo();
		Hashtable<String, String> result = new Hashtable<String, String>();
		result = super.getResult();
		shengfuinfo.cleanAll();

		shengfuinfo.setUserName(result.get(Key.KEY_USERNAME));
		shengfuinfo.setAllMoney(result.get(Key.KEY_ALLMONEY));
		shengfuinfo.setBeiShu(result.get(Key.KEY_BEISHU));
		shengfuinfo.setIshm(result.get(Key.KEY_ISHM));
		shengfuinfo.setAllNumber(result.get(Key.KEY_ANUMBER));
		shengfuinfo.setLeftNumber(result.get(Key.KEY_LEFTNUMBER));
		shengfuinfo.setOneMoney(result.get(Key.KEY_ONEMONEY));
		shengfuinfo.setBaoDiMoney(result.get(Key.KEY_BAODIMONEY));
		shengfuinfo.setTiCheng(result.get(Key.KEY_TICHENG));
		shengfuinfo.setIsManYuan(result.get(Key.KEY_ISMANYUAN));
		shengfuinfo.setJinDu(result.get(Key.KEY_RENQI));
		shengfuinfo.setLotteryCount(result.get(Key.KEY_LOTTERYCOUNT));
		shengfuinfo.setLotteryMoeny(result.get(Key.KEY_LOTTERYMONERY));
		shengfuinfo.setAddTime(result.get(Key.KEY_ADDTIME));
		shengfuinfo.setIssuc(result.get(Key.KEY_ISSUC));
		shengfuinfo.setIsUpload(result.get(Key.KEY_ISUPLOAD));
		shengfuinfo.setIsShow(result.get(Key.KEY_ISSHOW));
		shengfuinfo.setExpect(result.get(Key.KEY_EXPECT));
		shengfuinfo.setFilecode(result.get(Key.KEY_FILEORCODE));
		shengfuinfo.setGetmoney(result.get(Key.KEY_GETMONEY));
		shengfuinfo.setIsTXT(result.get(Key.KEY_ISTXT));
		shengfuinfo.setLotterystate(result.get(Key.KEY_LOTTERYSTATE));
		shengfuinfo.setProid(result.get(Key.KEY_PROID));
		shengfuinfo.setPlayID(result.get(Key.KEY_PLAYID));
		shengfuinfo.setPlayname(result.get(Key.KEY_PLAYNAME));
		shengfuinfo.setOpencode(result.get(Key.KEY_OPENCODE));
		shengfuinfo.setZhanjijipai(result.get(Key.KEY_ZHANJI_JINPAI));
		shengfuinfo.setZhanjiyinpai(result.get(Key.KEY_ZHANJI_YINPAI));
		shengfuinfo.setGoldDiamond(result.get(Key.KEY_ZHANJI_JINZUAN));
		shengfuinfo.setSilverDiamond(result.get(Key.KEY_ZHANJI_YINZUAN));
		shengfuinfo.setGoldStar(result.get(Key.KEY_ZHANJI_JINXING));
		shengfuinfo.setSilverStar(result.get(Key.KEY_ZHANJI_YINXING));
		shengfuinfo.setGoldCup(result.get(Key.KEY_ZHANJI_JINBEI));
		shengfuinfo.setLotName(result.get(Key.KEY_LOTNAME));
		shengfuinfo.setBaodi(result.get(Key.KEY_BAODI));

		ArrayList<ShengfuRenjiuTouzhuInfo> list = new ArrayList<ShengfuRenjiuTouzhuInfo>();
		ArrayList<Hashtable<String, String>> resultList = super.getListResult();
		int listCount = resultList.size();
		for (int i = 0; i < listCount; i++) {
			ShengfuRenjiuTouzhuInfo item = new ShengfuRenjiuTouzhuInfo();

			item.setHomeTeam(resultList.get(i).get(Key.KEY_HOMETEAM));
			item.setVisitingTeam(resultList.get(i).get(Key.KEY_GUESTTEAM));
			item.setDanMa(resultList.get(i).get(Key.KEY_ISDM));
			item.setShutin(resultList.get(i).get(Key.KEY_SHUTIN));
			item.setSimplegbname(resultList.get(i).get(Key.KEY_SIMPLEGBNAME));
			item.setPlur(resultList.get(i).get(Key.KEY_PLURL));
			item.setResultin(resultList.get(i).get(Key.KEY_RESULT));

			list.add(item);
		}

		ShengFuRenJiuDetailInfo.getInfo().setTouZhuInfo(list);

	}

	private HashMap<String, String> mapItem(String name, String value) {
		HashMap<String, String> map = new HashMap<String, String>();
		map.put(name, value);
		return map;
	}

}
